Here, we first include the source code, so that it can be exported to
an
examples/
subdir, with the following (note that the
#+ BEGIN_src
/
#+ END_src
should be changed to get rid of the space
character between
+
and
BEGIN
/
END
, and that the
:shebang
and following text should be on the
BEGIN_SRC
line I seem to have not quoted
these properly in this document):
#+name: helloworld
#+ BEGIN_src python :tangle examples/helloworld.py :noweb yes \\
:shebang #!/usr/bin/python :padline no :exports none
# -*- coding: utf-8 -*-
# Ceci est un exemple d'affichage d'une cha ne accentu e
name = raw_input("Quel est v tre nom ? ")
print "J'esp re que a va bien aujourd'hui", name
#+ END_src
Editing it with C-c will open an UTF-8 buffer, so hopefully, this will be consistent with the
utf-8
coding system declared on the second line.
The regeneration of the
examples/helloworld.py
file is made with
C-c C-v t
(babel tangling ).
Note that we don t add the
#!/usr/bin/python
first line in the source, as we want it to be added by the tangling process (which will also make the script executable).
Once this is done, the script may be run :
$ python examples/helloworld.py
Quel est v tre nom ? Fran ois
J'esp re que a va bien aujourd'hui, cher Fran ois
Now, to add the colorized rendering in the lecture book, we do (here again, remove the spaces):
# +BEGIN_latex
\inputminted python examples/helloworld.py
# +END_latex
And here it is, rendered by minted:
# -*- coding: utf-8 -*-
# Ceci est un exemple d'affichage d'une cha ne accentu e
name = raw_input("Quel est v tre nom ? ")
print "J'esp re que a va bien aujourd'hui, cher", name
Here are links to :
the source,
the PDF result, and
the generated Python program.